package com.study.a01mystream;

import java.util.ArrayList;

public class StreamDemo1 {
    public static void main(String[] args) {


    ArrayList<String> list1=new ArrayList<>();

    list1.add("张三风");
    list1.add("李四");
    list1.add("王五");
    list1.add("王六");
    list1.add("王七");
    list1.add("张无极");

    list1.stream().filter(name->name.startsWith("张")).filter(name->name.length()==3).forEach(name-> System.out.println(name));

   /* ArrayList<String> list2=new ArrayList<>();
        for (String s : list1) {
          if(s.startsWith("张")){
            list2.add(s);
          }
        }

        ArrayList<String> list3=new ArrayList<>();
        for (String s : list2) {
            if(s.length()==3){
                list3.add(s);
            }
        }
        for (String s : list3) {
            System.out.println(s);
        }*/
}
}
